﻿using System;
using System.Reflection;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using System.IO;

namespace Mnuemonix {
    //Read words from file and decompose the string into its relevant word parts
    class InputReader{

        Assembly myAssembly = Assembly.GetExecutingAssembly(); //Get executing environment to locate txt file

        public void ReadFromFile(String fileLocation, List<Word> wordList)
        {
            String fileAppend = "Mnuemonix.Resources." + fileLocation + ".txt";
            Word currentWord;
            string line;

            using (StreamReader stream = new StreamReader((myAssembly.GetManifestResourceStream(fileAppend)))) //stream text file
            {
                while (!stream.EndOfStream) //Read stream till EOF
                {
                    String [] wordDecomp = new String[12];
                    line = stream.ReadLine();
                    wordDecomp = line.Split('/');
                    currentWord = new Word(wordDecomp[0], wordDecomp[1], wordDecomp[2], wordDecomp[3], wordDecomp[4], wordDecomp[5], wordDecomp[6],
                        wordDecomp[7], wordDecomp[8], wordDecomp[9], wordDecomp[10], wordDecomp[11]);
                    wordList.Add(currentWord);
                }
            }
        }
    }
}
